package com.ruibo.modules.system.domain.vo;

import com.ruibo.modules.system.service.dto.SysDeptDto;
import com.ruibo.modules.system.service.dto.SysMenuDto;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruibo.modules.weixin.service.dto.RegionCodeDto;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: ruibo-parent
 * @description:
 * @author: Sun Feng
 * @create: 2020-05-20 17:24
 **/
public class TreeSelect implements Serializable {
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private Long id;

    /** 节点名称 */
    private String label;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelect> children;

    public TreeSelect()
    {

    }
    public TreeSelect(RegionCodeDto regionCode)
    {
        this.id = regionCode.getId();
        this.label = regionCode.getRegionName();
        this.children = regionCode.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }
    public TreeSelect(SysDeptDto dept)
    {
        this.id = dept.getId();
        this.label = dept.getDeptName();
        this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(SysMenuDto menu)
    {
        this.id = menu.getId();
        this.label = menu.getMenuName();
        this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public String getLabel()
    {
        return label;
    }

    public void setLabel(String label)
    {
        this.label = label;
    }

    public List<TreeSelect> getChildren()
    {
        return children;
    }

    public void setChildren(List<TreeSelect> children)
    {
        this.children = children;
    }
}
